<?php

class Application_Model_Goodsmenu extends Application_Model_DomainObject {
    protected $_id;
    protected $_name;
    protected $_parentId;
    protected $_isspecial;
    protected $_order;
    protected $_status;

     public static function getAll($condition = array())
    {
        if(!is_array($condition)){
            return false;
        }
        return self::getDao()->queryAll($condition);
    }
    public static function getFileds($parentId,$isspecial,$pagesize,$pageindex)
    {      
        return self::getDao()->queryPage(array("parentId = "=>$parentId," and isspecial = "=>$isspecial), " order desc ", $pagesize, $pageindex);
    }
    public static function getmenuname($id){      
        $name=self::getDao()->queryOne(array('id'=>$id));  
        if($name) return $name->_name;   
        else return false;     
    }
    public static function istopmenu($id){      
        $menu=self::getDao()->queryOne(array('id'=>$id)); 
        if($menu && $menu->_parentId==0) return true;    
        else return false;
    }
 /**
     * 添加
     */
    public static function addmenu($id,$parentId, $name, $order, $status,$isspecial)
    {
        if(empty($id)){
           $hot = new Application_Model_GoodsMenu();
        }else{
           $hot = Application_Model_GoodsMenu::load($id);  
        }
        $hot->parentId = $parentId;
        $hot->name = $name;
        $hot->order = $order;       
        $hot->status = $status;
        $hot->isspecial = $isspecial;
        $hot->save();
        return $hot->Id;
    }

     public static function getAllByParentId($parentId)
    {
        return self::getDao()->queryAll(array("parentId"=>$parentId)," order desc ");
    }
        

}